﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class BackSessionCls
    {
        public string BackSessionId;
        public string Url;
        public string SessionUserId;
    }

    public class BackSessionParser
    {
        public static BackSessionCls CreateInstance()
        {
            //tao 1 class trang....
            BackSessionCls oBackSessionCls = new BackSessionCls();
            return oBackSessionCls;
        }

        public static BackSessionCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            BackSessionCls oBackSessionCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oBackSessionCls;
        }


        public static BackSessionCls ParseFromDataRow(DataRow dr)
        {
            BackSessionCls OBackSessionCls = new BackSessionCls();
            OBackSessionCls.BackSessionId = (string)dr["BackSessionId"];
            OBackSessionCls.Url = (string)dr["Url"];
            OBackSessionCls.SessionUserId = (string)dr["SessionUserId"];

            return OBackSessionCls;
        }

        public static BackSessionCls[] ParseFromDataTable(DataTable dtTable)
        {
            BackSessionCls[] BackSessions = new BackSessionCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                BackSessions[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return BackSessions;
        }
    }
}


